'''
usage
class MyClass3(object, metaclass=Singleton):
    pass

one = MyClass3()
two = MyClass3()

two.a = 3
print(one.a)
#3
print(id(one))
#31495472
print(id(two))
#31495472
print(one == two)
#True
print(one is two)
#True


'''

class Singleton(type):
    def __init__(cls, name, bases, dict):
        super(Singleton, cls).__init__(name, bases, dict)
        cls._instance = None
    def __call__(cls, *args, **kw):
        if cls._instance is None:
            cls._instance = super(Singleton, cls).__call__(*args, **kw)
        return cls._instance
